package com.gitee.wsl.logger.format

import com.gitee.wsl.logger.LogFormatter
import com.gitee.wsl.logger.LogLevel
import com.gitee.wsl.logger.LogPrinter
import com.gitee.wsl.logger.format


class LogTxtDefaultFormat:LogFormatter {
    override fun format(
        level: LogLevel,
        tag: String,
        messageAny: Any?,
        throwable: Throwable?
    ): String {
        return if(throwable != null){
            "$messageAny  \n ${throwable.stackTraceToString()}"
        }else{
            "$messageAny"
        }
    }

    companion object{
        val instance = LogTxtDefaultFormat()
    }
}

fun LogPrinter.useLogTxtDefaultFormat(){
    format(LogTxtDefaultFormat.instance)
}